package core.manager.scriptManager
{
    import core.manager.scriptManager.event.*;
    import flash.events.*;

    public class ScriptManagerProxy extends EventDispatcher
    {
        private static var instance:ScriptManagerProxy;

        public function ScriptManagerProxy()
        {
            if (instance == null)
            {
                instance = this;
            }
            else
            {
                throw new Error("ScriptManagerProxy不能被实例化");
            }
            return;
        }// end function

        public function runScriptByName(param1:String, param2:Array = null) : void
        {
            this.dispatchEvent(new ScriptManagerProxyEvent(ScriptEvent.RUNSCRIPT, param1, null, null, param2));
            return;
        }// end function

        public function addApi(param1:String, param2:Function) : void
        {
            this.dispatchEvent(new ScriptManagerProxyEvent(ScriptEvent.ADDAPI, param1, param2));
            return;
        }// end function

        public function runScriptDirectly(param1:String) : void
        {
            this.dispatchEvent(new ScriptManagerProxyEvent(ScriptEvent.RUNSCRIPT, null, null, param1));
            return;
        }// end function

        public function removeApi(param1:String) : void
        {
            this.dispatchEvent(new ScriptManagerProxyEvent(ScriptEvent.REMOVEAPI, param1));
            return;
        }// end function

        public static function getInstance() : ScriptManagerProxy
        {
            if (instance == null)
            {
                return new ScriptManagerProxy;
            }
            return instance;
        }// end function

    }
}
